package com.houseman.workFlow.utils;

import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.houseman.workFlow.bean.Line;
import com.houseman.workFlow.bean.TaskArea;
import com.houseman.workFlow.bean.WorkFlowGraph;

public class JsonToGraph {

	Gson gson = new Gson();
	
	/**
	 * json转WorkFlowGraph对象
	 * @param json
	 * @return
	 */
	public WorkFlowGraph toGraph(String json) {
		
		return gson.fromJson(json, WorkFlowGraph.class);
	}
	
	/**
	 * json转TaskArea对象
	 * @param json
	 * @return
	 */
	public List<TaskArea> toTaskArea(String json) {
		
		return gson.fromJson(json, new TypeToken<List<TaskArea>>(){}.getType());
	}
	
	/**
	 * json转Line对象
	 * @param json
	 * @return
	 */
	public List<Line> toLine(String json) {
		
		return gson.fromJson(json, new TypeToken<List<Line>>(){}.getType());
	}
}
